package com.company.thread;




public class GuardedObject {


    private Object response;


    public Object getResponse() {
        synchronized (this) {
            while (response == null) {
                try {
                    this.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
        return response;
    }


    public void finishResponse(Object response){
        synchronized (this) {
            this.response = response;
            this.notifyAll();
        }
    }

}
